<?php
namespace App\Controllers\Goods;
use \App\Libs\Base\Constant;
use App\Models\Goods\SearchHistory;

/**
*	搜索历史记录
*/
class GetHistory extends \App\Libs\Base\BaseAction
{
	 protected function beforeRun() {
         parent::beforeRun();
         $this->needLogin = TRUE;
     }
	public function execute() {
		$uid = $user = $this->session->user->id;
		//查询是否存在KEY
		$searchHistory = SearchHistory::findAll(array(
			'uid = :uid:',
			'bind' => array('uid'=>$uid),
			"order" => "utime DESC",
		))->toArray();
		if( !empty( $searchHistory ) ){
			return \App\Libs\Views\Json::view(0, '成功', $searchHistory );
		}else{
			return \App\Libs\Views\Json::view(0, '成功', []);
		}
		
	}
}
